package com.example.ykbboom.universitytransportation.Util;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.NotificationCompat;

import com.example.ykbboom.universitytransportation.R;

import static android.content.Context.NOTIFICATION_SERVICE;

/**
 * Created by ykbboom on 2017/2/15 22:48
 * email：ykbpro@whut.edu.cn
 * 封装获取通知方法
 */

public class NotificationUtil {
    public static void getNotification(Intent intent, Context context){
        PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent,0);
        NotificationManager manager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
        Notification notification = new NotificationCompat.Builder(context)
                .setContentTitle("接单通知")
                .setContentText("您的捎带请求已被接单！")
                .setWhen(System.currentTimeMillis())
                .setAutoCancel(true)
                .setSmallIcon(R.drawable.notify)
                .setDefaults(NotificationCompat.DEFAULT_ALL)
                .setContentIntent(pendingIntent)
                .build();
        manager.notify(1,notification);
    }
}
